jQuery(document).ready(function () {

jQuery('textarea.wysiwyg:visible').tinymce({
	//script_url: WEBROOT_LIBS_URL + 'tiny_mce/tiny_mce.js',
	script_url: WEBROOT_LIBS_URL + 'tiny_mce/tiny_mce_gzip.php', // compressor
	theme: 'advanced',
	language: 'ru',
	// plugins
	plugins: 'pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist',
	// toolbar
	theme_advanced_buttons1: 'save,newdocument,pagebreak,|,print,preview,|,cut,copy,paste,pastetext,pasteword,cleanup,|,search,replace,|,undo,redo,|,charmap,template,styleselect,attribs,code,|,visualchars,nonbreaking,|,fullscreen',
	theme_advanced_buttons2: 'removeformat,styleprops,formatselect,fontselect,fontsizeselect,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,|,forecolor,backcolor',
	theme_advanced_buttons3: 'link,unlink,anchor,image,media,|,visualaid,tablecontrols,|,sub,sup,|,blockquote,advhr,|,insertdate,inserttime',
	// theme
	theme_advanced_toolbar_location: 'top',
	theme_advanced_toolbar_align: 'left',
	theme_advanced_statusbar_location: 'bottom',
	theme_advanced_resizing: true,
	theme_advanced_resize_horizontal: false,
	// css
	content_css: WEBROOT_CSS_URL + 'wysiwyg.css',
	style_formats: [
		{title: 'Скрыть', selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'hidden'},
		{title: 'Заголовки'},
		{title: 'Спец. заголовок', block: 'h1', classes: 'h1-spec'},
		{title: 'Абзацы'},
		{title: 'Спец. абзац', block: 'p', classes: 'p-spec'},
		{title: 'Текст'},
		{title: 'Спец. текст', inline: 'span', classes: 'span-spec'},
		{title: 'Ссылки'},
		{title: 'Спец. ссылка', selector: 'a', classes: 'a-spec'},
		{title: 'Lightbox', selector: 'a', classes: 'lightbox'},
		{title: 'Таблицы'},
		{title: 'Спец. таблица', selector: 'table', classes: 'table-spec'},
		{title: 'Спец. ряд', selector: 'tr', classes: 'tr-spec'},
		{title: 'Спец. ячейка', selector: 'td', classes: 'td-spec'},
		{title: 'Обтекание'},
		{title: 'Обтекать слева', selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'float-left'},
		{title: 'Обтекать справа', selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'float-right'},
		{title: 'Прекратить', selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'clear'}
	],
	formats: {
		alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'left'},
		aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'center'},
		alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'right'},
		alignfull: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'full'},
		bold: {inline: 'span', classes: 'bold'},
		italic: {inline: 'span', classes: 'italic'},
		underline: {inline: 'span', classes: 'underline', exact: true},
		strikethrough: {inline: 'del'}
	},
	font_size_classes: 'xx-small,x-small,small,medium,large,x-large,xx-large',
	// lists
	//template_external_list_url: 'lists/template_list.js',
	//external_link_list_url: 'lists/link_list.js',
	//external_image_list_url: 'lists/image_list.js',
	//media_external_list_url: 'lists/media_list.js',
	// template replace values
	//template_replace_values: {},
	// file browser
	file_browser_callback: 'tinyBrowser',
	convert_urls: false
});

});